package utils

import (
	"fmt"
	"gopkg.in/ini.v1"
)


func ServerBind() string{
	/*
	used for configuring server bind and port
	*/
	var (
		cfg *ini.File
		err error
		serverHost string
		serverPort string
		bindAddr string
	)

	cfg, err = ini.Load("./conf/config.ini")

	if err != nil {
		fmt.Println("read file error, use default config", err)
		bindAddr = "127.0.0.1:8080"
		return bindAddr
	}
	serverHost = cfg.Section("Server").Key("BIND").Value()
	serverPort = cfg.Section("Server").Key("PORT").Value()
	bindAddr = serverHost + ":" + serverPort

	return bindAddr
}

const SuccessCode int = 0
const SuccessMsg string = "Success"
const ErrorCode int = -1
const TIMEFORMAT string = "2006-01-02 15:04:05"

const B int64 = 1024
const KB int64 = 1024 * 1024
const MB int64 = 1024 * 1024 * 1024
const GB int64 = 1024 * 1024 * 1024 * 1024
const TB int64 = 1024 * 1024 * 1024 * 1024 * 1024
